package com.homedo.odin.solution.controller.mng;

import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.odin.solution.contract.mng.ClassifyDataResp;
import com.homedo.odin.solution.contract.mng.CommonTypeDataReq;
import com.homedo.odin.solution.service.bizservice.mng.MngStandardTypesBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 行业规范分类
 *
 * @author: zhaoxudong
 * @date: 2018/4/10 14:53
 * @Description:
 */
@Api(description = "行业规范", tags = {"Standard"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/mng/standard_types")
public class MngStandardTypesController extends BaseController<MngStandardTypesBizService> {

    @ApiOperation(value = "OMS_获取规范分类列表", notes = "OMS_获取规范分类列表", response = ClassifyDataResp.class)
    @GetMapping
    public ResultData list(
            @ApiParam(value = "规范组", required = false) @RequestParam(value = "firstClassify", required = false) Integer firstCassify,
            @ApiParam(value = "当前页码", required = true) @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页记录数", required = true) @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        ClassifyDataResp resp = baseService.list(firstCassify, pageNum, pageSize);
        return ResultData.newInstance(resp);
    }

    @ApiOperation(value = "OMS_新增规范分类", notes = "OMS_新增规范分类")
    @PostMapping
    public ResultData add(@RequestBody CommonTypeDataReq req) {
        baseService.add(req);
        return ResultData.newInstance();
    }

    @ApiOperation(value = "OMS_修改规范分类", notes = "OMS_修改规范分类")
    @PutMapping
    public ResultData edit(@RequestBody CommonTypeDataReq req) {
        baseService.edit(req);
        return ResultData.newInstance();
    }

    @ApiOperation(value = "OMS_删除规范分类", notes = "OMS_删除规范分类")
    @DeleteMapping("{id}")
    public ResultData del(@PathVariable("id") Integer id) {
        baseService.del(id);
        return ResultData.newInstance();
    }

}
